package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;

/**
 * paas模块默认操作权限枚举
 * @author kaka
 * @date 2019/3/17 14:16
 * @since v1.0
 * @version v1.0
 */
@Getter
public enum DefaultPaasModulePermissionEnum {


    /**
     * 默认查看权限
     */
    READ("read", "enum.defaultPaasModulePermission.name.read", 0),
    /**
     * 默认新建权限
     */
    CREATE("create", "enum.defaultPaasModulePermission.name.create", 0),
    UPDATE("update", "enum.defaultPaasModulePermission.name.update", 0),
    DELETE("delete", "enum.defaultPaasModulePermission.name.delete", 0),
    IMPORTS("imports", "enum.defaultPaasModulePermission.name.imports", 0),
    EXPORT("export", "enum.defaultPaasModulePermission.name.export", 0),
    print("print", "enum.defaultPaasModulePermission.name.print", 0),
    ESIGN("esign", "enum.defaultPaasModulePermission.name.esign", 0),
    FILE_CABINET_VISIBLE("fileCabinetVisible", "enum.defaultPaasModulePermission.name.fileCabinetVisible", 1),
    FILE_CABINET_DELETE("fileCabinetDelete", "enum.defaultPaasModulePermission.name.fileCabinetDelete", 0),
    /**
     * 移交
     */
    HANDLE_OVER("handleOver", "enum.defaultPaasModulePermission.name.handleOver", 0),
    ;

    /**
     * paas代表PermissionTermsPojo内字段对应的内容，如"read","create"
     */
    private String alias;

    /**
     * alias字段对应的中文描述，比如 "read" -> "查看", "create" -> "新建"
     */
    private String name;

    /**
     * 默认权限值，大部分应该是为0,及默认无权限
     */
    private int value;

    DefaultPaasModulePermissionEnum(String alias, String name, int value) {
        this.alias = alias;
        this.name = name;
        this.value = value;
    }

    /**
     * 获取所有枚举值
     * @return 所有枚举值对应的列表
     */
    public static List<DefaultPaasModulePermissionEnum> getAllEnum() {
        return new ArrayList<>(Arrays.asList(values()));
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
